package com.example.dota2draftsimulator.fragments;

import java.util.List;

import com.example.dota2draftsimulator.R;
import com.example.dota2draftsimulator.adapters.CustomSpinnerAdapter;

import android.app.Dialog;
import android.app.DialogFragment;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.hardware.Camera.Size;
import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;

public class SettingFrament extends DialogFragment{

	private TextView settingsTextView;
	private TextView difficultyTextView;
	private TextView sideTextView;
	private TextView positionTextView;
	private Spinner difficultySpinner;
	private Spinner sideSpinner;
	private Spinner positionSpinner;
	private View view;
	private Typeface type;
	private ArrayAdapter adapter1;
	private ArrayAdapter adapter2;
	private ArrayAdapter adapter3;
	
	String[] difficultyList = {"Easy" + "Normal" + "Hard"};
	String[] sideList = {"Radiant" + "Dire" + "Random"};
	String[] positionList = {"First" + "Second" + "Random"};
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		view = inflater.inflate(com.example.dota2draftsimulator.R.layout.setting_fragment, container);
		type = Typeface.createFromAsset(getActivity().getAssets(),"OPTIMUSPRINCEPSSEMIBOLD.TTF"); 
				
		settingsTextView = (TextView) view.findViewById(R.id.setting_text_view);
		difficultyTextView = (TextView) view.findViewById(R.id.difficulty_text_view);
		sideTextView = (TextView) view.findViewById(R.id.side_text_view);
		positionTextView = (TextView) view.findViewById(R.id.position_text_view);
		
		difficultySpinner = (Spinner) view.findViewById(R.id.spinner_difficulty);
		sideSpinner = (Spinner) view.findViewById(R.id.spinner_side);
		positionSpinner = (Spinner) view.findViewById(R.id.spinner_position);
		setArrayAdapters();
		
		settingsTextView.setText(Html.fromHtml("<p><u>Settings</u></p>"));
		settingsTextView.setTypeface(type);
		settingsTextView.setTextSize(30);
		
		difficultyTextView.setText("Difficulty");
		difficultyTextView.setTypeface(type);
		difficultyTextView.setTextSize(30);
		
		sideTextView.setText("Side");
		sideTextView.setTypeface(type);
		sideTextView.setTextSize(30);
		
		positionTextView.setText("Position");
		positionTextView.setTypeface(type);
		positionTextView.setTextSize(30);
		
		return view;
	}
	
	private void setArrayAdapters() {
		adapter1 = new CustomSpinnerAdapter(getActivity(), R.array.setting_difficulty, difficultyList);
        adapter1.setDropDownViewResource(R.layout.custom_spinner_style);
        difficultySpinner.setAdapter(adapter1);
        
        adapter2 = new CustomSpinnerAdapter(getActivity(), R.array.setting_side, sideList);
        adapter2.setDropDownViewResource(R.layout.custom_spinner_style);
        sideSpinner.setAdapter(adapter2);
        
        adapter3 = new CustomSpinnerAdapter(getActivity(), R.array.setting_position, positionList);
        adapter3.setDropDownViewResource(R.layout.custom_spinner_style);
        positionSpinner.setAdapter(adapter3);
	}
	
	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		Dialog dialog = super.onCreateDialog(savedInstanceState);
		dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
		dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
		return dialog;
	}

}
